<template>
	<page-header-wrapper>
		<a-card :bordered="false">
			<div class="table-page-search-wrapper">
				<a-form layout="inline">
					<a-row :gutter="48">
						<a-col :md="8" :sm="24">
							<a-form-item label="关键词搜索">
								<a-input v-model="queryParam.name" placeholder="请输入学校关键词"></a-input>
								</a-select>
							</a-form-item>
						</a-col>
						<a-col :md="8" :sm="24">
							<a-form-item label="学校类别">
								<a-select v-model="queryParam.school_type_id" placeholder="请选择学校类别">
									<a-select-option v-for="(item,index) in schoolTypeList" :value="item.id">
										{{item.name}}
									</a-select-option>
								</a-select>
							</a-form-item>
						</a-col>
						<a-col :md="8" :sm="24">
							<span class="table-page-search-submitButtons">
								<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
								<a-button style="margin-left: 8px" @click="() => this.queryParam = {}">重置</a-button>
								<a-button style="margin-left: 8px" type="primary" icon="plus" @click="handleAdd()">新建
								</a-button>
							</span>
						</a-col>
					</a-row>
				</a-form>
			</div>
			<s-table ref="table" size="default" rowKey="key" :columns="columns" :data="loadData" showPagination="auto">
				<span slot="name" slot-scope="text">
					<ellipsis :length="30" tooltip>{{ text }}</ellipsis>
				</span>
				<span slot="content" slot-scope="text">
					<ellipsis :length="30" tooltip>{{ text }}</ellipsis>
				</span>
				<span slot="action" slot-scope="text, record">
					<a-button v-if="record.sh==1" style="margin: 0 8px 8px 0" type="primary" size="small"
						@click="modalShow(record)">审核
					</a-button>
					<a-button style="margin: 0 8px 8px 0" size="small" v-else-if="record.sh==2" disabled>已通过</a-button>
					<a-button style="margin: 0 8px 8px 0" size="small" v-else-if="record.sh==3" disabled>已拒绝</a-button>
				</span>
			</s-table>
		</a-card>
	</page-header-wrapper>
</template>

<script>
	import {
		STable,
		Ellipsis
	} from '@/components'

	import {
		getGoodsList,
		getGoodInfo,
		deleGood,
		editGood,
		addGood
	} from '../../api/shopManage'

	import {
		typeListUrl,
		brandListUrl
	} from '../../api/system'

	const columns = [{
			title: 'ID',
			dataIndex: 'id'
		}, {
			title: '标题',
			dataIndex: 'title',
			scopedSlots: {
				customRender: 'name'
			}
		},
		{
			title: '内容',
			dataIndex: 'content',
			scopedSlots: {
				customRender: 'content'
			}
		},
		{
			title: '操作',
			dataIndex: 'action',
			fixed: 'right',
			scopedSlots: {
				customRender: 'action'
			}
		}
	]

	export default {
		name: 'TableList',
		components: {
			STable,
			Ellipsis,
		},
		data() {
			this.columns = columns
			return {
				visible: false,
				// 查询参数
				queryParam: {},
				// 加载数据方法 必须为 Promise 对象
				loadData: parameter => {
					parameter.page = parameter.pageNo;
					const requestParameters = Object.assign({}, parameter, this.queryParam)
					console.log('loadData request parameters:', requestParameters)
					return getGoodsList(requestParameters)
						.then(res => {
							res.data.pageNo = parseInt(res.data.page);
							res.data.totalCount = res.data.count;
							return res.data;
						})
				}
			}
		},
		methods: {}
	}
</script>

<style>
</style>
